build: docker build setting and make guideline#318
Conversation
Summary of ChangesHello @2yunseong, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 이 PR은 인프라 변경에 따라 프론트엔드 애플리케이션의 Docker 기반 배포 및 로컬 개발 환경 설정을 도입합니다. 이를 통해 개발자들이 일관된 환경에서 애플리케이션을 빌드하고 실행할 수 있도록 지원하며, 배포 과정을 문서화하여 효율성을 높이는 것을 목표로 합니다. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
이 PR은 Docker 빌드 설정과 가이드 문서를 추가하여 배포 프로세스를 개선하는 좋은 시도입니다. 몇 가지 개선점을 제안합니다. docker-deployment-guide.md 문서의 워크플로우가 일부 혼란스러워 명확하게 수정할 필요가 있습니다. local-docker-start-guide.md의 빌드 명령어는 로컬 개발 환경에 더 적합하게 단순화할 수 있습니다. 마지막으로, Dockerfile에서 .env.production 파일을 최종 이미지에 복사하는 부분은 이미지의 재사용성을 낮추고 잠재적인 보안 위험을 초래할 수 있어 수정이 필요해 보입니다. 자세한 내용은 각 파일에 대한 개별 코멘트를 참고해주세요.
| COPY --from=builder /app/.next ./.next | ||
| COPY --from=builder /app/public ./public | ||
| COPY --from=builder /app/next.config.js ./next.config.js | ||
| COPY --from=builder /app/.env.production ./.env.production |
There was a problem hiding this comment.
최종 runner 이미지에 .env.production 파일을 복사하는 것은 몇 가지 문제를 일으킬 수 있습니다.
- 재사용성 저하: 빌드 시점의 환경 변수 값이 이미지에 하드코딩되어, 다른 환경(e.g., staging, production)에서 동일한 이미지를 다른 설정으로 재사용하기 어렵게 만듭니다.
- 보안 위험:
.env.production파일에 API 키와 같은 민감한 정보가 포함된 경우, 해당 정보가 이미지 내에 그대로 저장됩니다. 이 이미지가 외부에 노출되면 보안 사고로 이어질 수 있습니다.
Next.js는 NEXT_PUBLIC_으로 시작하는 변수를 빌드 시점에 에셋에 포함시키므로, builder 스테이지에서 .env.production 파일을 사용하는 것은 올바른 접근입니다.
하지만 runner 스테이지에서는 이 파일을 복사하는 대신, docker run 명령어 실행 시 -e 옵션이나 --env-file 옵션을 사용하여 런타임에 환경 변수를 주입하는 것이 좋습니다.
따라서 이 라인을 제거하여 런타임 환경 변수에 의존하도록 수정하는 것을 강력히 권장합니다.
There was a problem hiding this comment.
docker run -p 3000:3000 \
--env-file frontend/.env.production \
econo-recruit-fe:versiongemini 리뷰처럼 --env-file 추가해서 배포할때 env 를 숨기면 어떨까요?
| docker buildx build \ | ||
| --platform linux/amd64,linux/arm64 \ | ||
| -t leeyunseong/econo-recruit-fe:<version> \ | ||
| -f frontend/Dockerfile frontend \ | ||
| --push | ||
| ``` | ||
|
|
||
| ## 2) Run locally | ||
|
|
||
| ```bash | ||
| docker run -d \ | ||
| --name econo-recruit-fe \ | ||
| -p 3000:3000 \ | ||
| econo-recruit-fe:<version> | ||
| ``` | ||
|
|
||
| ## 3) Push to registry | ||
|
|
||
| 먼저 Docker Hub Push 권한을 관리자에게 요청 부탁드립니다. | ||
|
|
||
| ```bash | ||
| docker tag econo-recruit-fe:<version> leeyunseong/econo-recruit-fe:<version> | ||
| docker push leeyunseong/econo-recruit-fe:<version> | ||
| ``` |
There was a problem hiding this comment.
배포 가이드의 내용이 일부 혼란스럽게 작성되어 있어 사용자가 따라하기 어려울 수 있습니다. 현재 가이드는 빌드, 로컬 실행, 푸시 단계가 서로 일관되지 않고 중복되는 부분이 있습니다.
- 이미지 이름 불일치: 1번 단계에서 빌드한 이미지(
leeyunseong/...)와 2번에서 실행하려는 이미지(econo-recruit-fe) 이름이 다릅니다. - 푸시 단계 중복: 1번의
build --push와 3번의push가 중복됩니다.
명확한 워크플로우를 위해, 빌드와 푸시를 한번에 하는 방법 또는 빌드/테스트/푸시를 단계별로 하는 방법 중 하나로 통일하여 안내하는 것을 권장합니다.
또한, leeyunseong/econo-recruit-fe와 같이 개인 Docker Hub 사용자 이름을 사용하는 대신, <YOUR_DOCKERHUB_USERNAME>/<IMAGE_NAME>과 같은 플레이스홀더를 사용하거나 조직의 리포지토리를 사용하도록 안내하는 것이 좋습니다.
| docker buildx build \ | ||
| --platform linux/amd64,linux/arm64 \ | ||
| -t econo-recruit-fe:<version> \ | ||
| -f frontend/Dockerfile frontend \ |
There was a problem hiding this comment.
로컬 개발 환경에서 이미지를 빌드하는 경우, 보통 현재 사용 중인 아키텍처(e.g., amd64 or arm64)에 대해서만 빌드하면 충분합니다. docker buildx를 사용하여 여러 플랫폼용으로 빌드하는 것은 배포용 이미지를 만들 때 더 적합합니다.
로컬 실행 가이드인 만큼, 개발자들이 더 간단하게 사용할 수 있도록 docker build 명령어로 변경하는 것을 제안합니다. 이렇게 하면 --platform 옵션에 대해 고민할 필요가 없고, 빌드된 이미지가 바로 로컬 도커 데몬에 저장되어 실행하기 편리합니다.
| docker buildx build \ | |
| --platform linux/amd64,linux/arm64 \ | |
| -t econo-recruit-fe:<version> \ | |
| -f frontend/Dockerfile frontend \ | |
| docker build -t econo-recruit-fe:<version> -f frontend/Dockerfile frontend |
cho-in-sik
left a comment
There was a problem hiding this comment.
설정 감사합니다! 적용되면 가이드대로 진행해보겠습니다~
dle234
left a comment
There was a problem hiding this comment.
가이드라인 잘 적어주셨네요~ 감사합니다! 질문 몇개 남겨놨어요!
| COPY --from=builder /app/.next ./.next | ||
| COPY --from=builder /app/public ./public | ||
| COPY --from=builder /app/next.config.js ./next.config.js | ||
| COPY --from=builder /app/.env.production ./.env.production |
There was a problem hiding this comment.
docker run -p 3000:3000 \
--env-file frontend/.env.production \
econo-recruit-fe:versiongemini 리뷰처럼 --env-file 추가해서 배포할때 env 를 숨기면 어떨까요?
| "dev": "next dev", | ||
| "build": "next build", | ||
| "start": "node database.js && next start", | ||
| "start:no-db": "next start", |
There was a problem hiding this comment.
배포할때 db.js 없이 실행하는 이유가 있을까요?
((사실 database.js 가 있는지도 처음 알았네요😭 이제는 사용하지 않는 로직인가요..?
There was a problem hiding this comment.
백업용이라 production에서는 필요없을 듯 합니다!
There was a problem hiding this comment.
별도의 sqlite가 서버에 셋팅되고 있지않아서, no-db옵션을 추가한 것도 있습니다 ㅎㅎ
관련 이슈
작업 분류
PR을 통해 해결하려는 문제가 무엇인가요? 🚀
PR에서 핵심적으로 변경된 부분이 어떤 부분인가요? 👀
핵심 변경사항 이외 추가적으로 변경된 사항이 있나요? ➕
추가적으로, 리뷰어가 리뷰하며 알아야 할 정보가 있나요? 🙌
이런 부분을 신경써서 봐주셨으면 좋겠어요. 🙋🏻♂️
체크리스트 ✅
reviewers설정assignees설정label설정